<?php
class Default_Model_product extends Zend_Db_Table
{
	public function get_product_details($id)
	{
	    $ns = new Zend_Session_Namespace('lang');
	    $lang=$ns->lang;
		$db = Zend_Registry::get('connectDb');
		$select = $db->select()
		          ->from('details_product', array('id','title','introtext','images','fulltext')) 
		          ->where('published = ?', '1')
		          ->where('language_id = ?',$lang)
		          ->where('id = ?',$id);
		$result = $db->fetchAll($select);
	    return $result;          
		
	}	
	
	public function get_commnets($id)
	{
	    $ns = new Zend_Session_Namespace('lang');
	    $lang=$ns->lang;
		$db = Zend_Registry::get('connectDb');
		$select = $db->select()
		          ->from('comments', array('id','title','fulltext')) 
		          ->where('published = ?', '1')
		          ->where('product_id = ?',$id)
		          ->order('id DESC');
		$result = $db->fetchAll($select);
	    return $result;          
		
	}	
	
	public function save_commnents($data)
	{
	        $db = Zend_Registry::get('connectDb');
			$fulltext = stripslashes($data['fulltext']);
			$data1 = array(
			              	'title'         	=> $data['tieude'],
							'name'			    => $data['name1'],
		  					'email'		    	=> $data['email'],
		  					'address'		    => $data['address'],
							'fulltext'			=> $fulltext,
			                'product_id'	    => $data['id'],
	                      	'published'	        => '0',
		  				  );
	        $db->insert('comments', $data1);
	}	
	
}